import Vue from 'vue'
import Router from 'vue-router'
import Login from "../components/login/Login"
import Register from "../components/register/Register";
import Home from "../components/Home";
import Index from "../components/index/Index"
import Library from "../components/library/Library";
import Labor from "../components/labor/Labor";
import Space from "../components/space/Space";
import Info from "../components/space/Info";
import MyNote from "../components/space/Note";
import MyPaper from "../components/space/Paper";
import LibraryIndex from "../components/library/LibraryIndex";
import Content from "../components/library/Content";
import Result from "../components/library/Result";
import Details from "../components/library/Details";
import Note from "../components/library/Note";
import LaborData from "../components/labor/LaborData";
import UserList from "../components/labor/UserList";
import NotFound from "../components/utils/NotFound";
import AdminIndex from "../components/admin/user/AdminIndex";
import AdminLabor from "../components/admin/content/labor/AdminLabor";
import AdminLaborData from "../components/admin/content/labor/LaborData"
import AdminLibraryIndex from "../components/admin/content/library/AdminLibraryIndex";
import AdminDetails from "../components/admin/content/library/AdminDetails";
import ManageDirection from "../components/admin/content/library/ManageDirection";

Vue.use(Router)
const routes = [
  {
    path:'/',
    name:'Entry',
    redirect: '/index'
  },
  {
    path: '/login',
    name: 'Login',
    component: Login
  },
  {
    path: '/register',
    name: 'Register',
    component: Register
  },
  {
    path: '/home',
    name: 'Home',
    component: Home,
    redirect:'/index',
    meta:{
      requireAuth:true
    },
    children: [
      {
        path:'/index',
        name:'Index',
        component:Index,
        meta:{
          requireAuth:true
        }
      },
      {
        path:'/labor',
        name:'Labor',
        component: Labor,
        redirect: '/labor/data',
        children: [
          {
          path:'/labor/data',
          name:'LaborData',
          component: LaborData,
          meta: {
            requireAuth: true
            }
          },
          {
            path:'/labor/list',
            name:'UserList',
            component: UserList,
            meta: {
              requireAuth: true
            }
          }
        ]
      },
      {
        path:'/library',
        name:'LibraryIndex',
        redirect: '/library/papers',
        component: LibraryIndex,
        children: [
          {
            path:'/library/papers',
            name:'Library',
            component: Library,
            meta: {
              requireAuth: true
            }
          },
          {
            path:`/library/result?select=:select&key=:key`,
            name:'Result',
            component: Result,
            meta: {
              requireAuth: true
            }
          },
          {
            path:'/library/details?id=:paperId',
            name:'Details',
            component: Details,
            meta: {
              requireAuth: true,
            }
          },
          {
            path:'/library/content?id=:paperId&url=:url',
            name:'Content',
            component: Content,
            meta: {
              requireAuth: true
            }
          },
          {
            path:'/library/note?paperId=:paperId&noteId=:noteId&edit=:editable',
            name:'Note',
            component: Note,
            meta: {
              requireAuth: true
            }
          },
        ]
      },
      {
        path:'/space',
        name:'Space',
        component: Space,
        redirect:'/space/info',
        children:[
          {
            path:'/space/info',
            name:'Info',
            component:Info,
            meta:{
              requireAuth:true
            }
          },
          {
            path:'/space/paper',
            name:'Paper',
            component:MyPaper,
            meta:{
              requireAuth:true
            }
          },
          {
            path:'/space/note',
            name:'MyNote',
            component:MyNote,
            meta:{
              requireAuth:true
            }
          }
        ]
      }
    ]
  },
  {
    name:'AdminIndex',
    path:'/admin',
    component: AdminIndex,
    redirect:'/admin/labor/data',
    children: [
      {
        path:'/admin/labor',
        name:'AdminLabor',
        component: AdminLabor,
        children: [
          {
            path:'/admin/labor/data',
            name:'AdminLaborData',
            component:AdminLaborData,
            meta: {
              requireAuth: true
            }
          },
          {
            path:'/admin/labor/list',
            name:'AdminLaborUserList',
            component:UserList,
            meta: {
              requireAuth: true
            }
          },
        ]
      },
      {
        path:'/admin/library',
        name:'AdminLibraryIndex',
        component: AdminLibraryIndex,
        redirect: '/admin/library/library',
        children: [
          {
            path:'/admin/library/library',
            name:'AdminLibrary',
            component:Library,
            meta: {
              requireAuth: true
            }
          },
          {
            path:`/admin/library/result?select=:select&key=:key`,
            name:'AdminResult',
            component: Result,
            meta: {
              requireAuth: true
            }
          },
          {
            path:'/admin/library/details?id=:paperId',
            name:'AdminDetails',
            component: AdminDetails,
            meta: {
              requireAuth: true,
            }
          },
          {
            path:'/admin/library/content?id=:paperId&url=:url',
            name:'AdminContent',
            component: Content,
            meta: {
              requireAuth: true
            }
          },
          {
            path:'/admin/library/note?paperId=:paperId&noteId=:noteId&edit=:editable',
            name:'AdminNote',
            component: Note,
            meta: {
              requireAuth: true
            }
          },
          {
            path:'/admin/library/direction',
            name:'AdminDirection',
            component: ManageDirection,
            meta: {
              requireAuth: true
            }
          }
        ]
      },
    ]
  },
  {
    path: '*',
    component: NotFound
  }
]

const router = new Router({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})
export default router
